package Thread;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;

class MyThreadPoolExecutor{
    private BlockingQueue<Runnable> queue = new LinkedBlockingQueue<>();

    public MyThreadPoolExecutor(int n) {
        for (int i = 0; i < n; i++) {
            while (true) {
                Thread thread = new Thread(()->{
                    try {
                        Runnable runnable = queue.take();
                        runnable.run();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                });
                thread.start();
            }
        }
    }
    public void submit(Runnable runnable) throws InterruptedException {
        queue.put(runnable);
    }
}
public class ThreadDemo29 {

    public static void main(String[] args) {

    }

}
